# Contributor: Dominika Liberda <ja@sdomi.pl>
# Maintainer: Dominika Liberda <ja@sdomi.pl>
pkgname=nvidia-src
pkgver=535.86.05
pkgrel=0
pkgdesc="NVIDIA Linux open GPU kernel module source (sources, AKMS)"
url="https://github.com/NVIDIA/open-gpu-kernel-modules"
# x86_64/aarch64 only
arch="noarch !riscv64 !s390x !armhf !armv7 !x86 !ppc64le"
license="MIT AND GPL-2.0-or-later"
depends="akms"
source="$pkgname-$pkgver.tar.gz::https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/$pkgver.tar.gz"
builddir="$srcdir/open-gpu-kernel-modules-$pkgver"
options="!check" # no tests

package() {
	mkdir -p "$pkgdir"/usr/src
	cp -r "$builddir" "$pkgdir"/usr/src/nvidia-$pkgver

	cat > "$pkgdir"/usr/src/nvidia-$pkgver/AKMBUILD <<EOF
modname=nvidia
modver=$pkgver-r$pkgrel
makedepends="linux-headers"
built_modules="kernel-open/nvidia.ko \
	kernel-open/nvidia-drm.ko \
	kernel-open/nvidia-modeset.ko \
	kernel-open/nvidia-uvm.ko \
	kernel-open/nvidia-peermem.ko \
	"

build() {
	cp -r "\$srcdir"/* .
	make modules \$MAKEFLAGS
}
EOF
}

sha512sums="
da1964921f2f0a07e136ad5301b633c01d1e045b5fbb4ebb32f5d57471a89e649a1b653bbbb62e97755d070ce911c442ceaac2fb3d81baa53af75f4123075308  nvidia-src-535.86.05.tar.gz
"
